﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

namespace FASTControlUI
{
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class SettingPage : Page
    {
        public SettingPage()
        {
            this.InitializeComponent();
        }

        private void TextBlock_SelectionChanged(object sender, RoutedEventArgs e)
        {

        }

        private void ColorPicker_ColorChanged(ColorPicker sender, ColorChangedEventArgs args)
        {
            MainConfig.Current.LineColor = args.NewColor;
        }

        private void colorPicker_Expanding(Expander sender, ExpanderExpandingEventArgs args)
        {
            colorPicker.Color = MainConfig.Current.LineColor;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MainConfig.Current.SetStyle(BackStyleControl.FastStyle.Mica);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            MainConfig.Current.SetStyle(BackStyleControl.FastStyle.Acrylic);
        }

        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (HomePage.serial.device == null)
            {
                MainWindow.Current.NotifyUser("FAST设备串口通讯失败\r\n", SDKTemplate.NotifyType.StatusMessage);
                return;
            }
            switch (button.Tag as string)
            {
                case "save":
                    _ = HomePage.serial.Write("SAVE");
                    break;
                case "read":
                    _ = HomePage.serial.Write("READ");
                    break;
                default:
                    break;
            }
        }
    }

}
